﻿using CommunityToolkit.Mvvm.ComponentModel;
using DocumentFormat.OpenXml.Vml.Spreadsheet;
using FileManager.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using Size = System.Windows.Size;

namespace FileManager.ViewModel
{
    internal partial class BookWindowViewModel : ObservableObject
    {
        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(ProgressDisplay))]
        //[NotifyCanExecuteChangedFor(nameof(NextFileCommand))]
        //[NotifyCanExecuteChangedFor(nameof(PreFileCommand))]
        [NotifyPropertyChangedFor(nameof(ProgressDisplay))]
        private int _idx;

        [NotifyPropertyChangedFor(nameof(ProgressDisplay))]
        [ObservableProperty]
        //[NotifyCanExecuteChangedFor(nameof(NextFileCommand))]
        //[NotifyCanExecuteChangedFor(nameof(PreFileCommand))]
        private int _maxNum;

        private BookWindow view;
    
        [ObservableProperty]
        private DateTime _startDate=DateTime.Now;
        [ObservableProperty]
        private DateTime _endDate = DateTime.Now;
        [ObservableProperty]
        private DateTime _signDate = DateTime.Now;

        [ObservableProperty]
        private string _xmlFile;
        [ObservableProperty]
        private string _reNameText;

        [ObservableProperty]
        private bool _autoSave;
        [ObservableProperty]
        private BitmapImage _imgNow;
        [ObservableProperty]
        private string _fileDetal;

        [ObservableProperty]
        private bool _HasFile;
        [ObservableProperty]
        private bool _isStatusBarMessageVisible;
        private DispatcherTimer _statusBarTimer;
        [ObservableProperty]
        private string _dataPath;

        [ObservableProperty]
        private string _searchText;
        [ObservableProperty]
        private MetaData _currentFile;
        [ObservableProperty]
        private string _tagText;

        [ObservableProperty]
        private ObservableCollection<string> _banks;
        [ObservableProperty]
        private bool _lockTag;

        [ObservableProperty]
        private string _selectedBank;
        private List<DW> dwList = new List<DW>();
        internal Dictionary<string, FileInfo> existsFile = new Dictionary<string, FileInfo>();
        [ObservableProperty]
        private ObservableCollection<Letter> _letterList=new ObservableCollection<Letter>();
        public LetterDataCollection LetterDatas = new LetterDataCollection();
        [ObservableProperty]
        private Letter _letterNow;

        [ObservableProperty]
        private bool _jumpVis =false;

        [ObservableProperty]
        private bool _isPreview = true;

        private int zoom = 0;
        private Size[] sizeList = new Size[] { new Size(550, 780), new Size(650,900), new Size(780, 1100), new Size(975, 1380), new Size(1625, 2290)};
        public string ProgressDisplay => $"{Idx}/{MaxNum}";

        private bool isSaving = false;
        public BookWindowViewModel(BookWindow view)
        {
            _idx = 0;
            this.view = view;
            var Ini = new MysToolCore.InIReader("config", Encoding.UTF8);
            Ini.ReadString("Book", "bookPath", "book.xml");
        }
        [ObservableProperty]
        private bool isCachePic = false;

    }
}
